package cn.ddiancan.dm.domain;

import cn.ddiancan.dm.constants.StatusEnum;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.util.StringUtils;

import java.util.Date;

import static cn.ddiancan.dm.constants.Constant.DM_PREFIX;

@Setter
@Getter
public class DataMigrationLogDTO {
    private Long id;
    private String batchNo;
    private String tableName;
    private String executeSql;
    private String parameters;
    private int status; // 1.初始化2.处理中3处理完成,4业务失败，5异常失败
    private String statusName;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date executeTime;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date finishTime;
    private String message;

    public String generateBatchNo() {
        return DM_PREFIX + System.currentTimeMillis();
    }

    public String getStatusName() {
        return StatusEnum.getStatusEnum(status).getDescription();
    }
}
